package cas.ihep.pwa.evtgen;

import java.util.HashMap;

public class EvtModel {

    private HashMap<String,EvtDecayBase> modelNameHash,commandNameHash;

    private final static String ppps[]={"AngH2",
            "AngPar",
            "AngSam3",
            "AngSam",
            "AV2GV",
            "BHADRONIC",
            "Body3",
            "BSQUARK",
            "BTO2PI_CP_ISO",
            "BTO3PI_CP",
            "BTO4PI_CP",
            "BTOKD3P",
            "BTOKPI_CP_ISO",
            "BTOKPIPI_CP",
            "BTOSLLALI",
            "BTOSLLBALL",
            "BTOXSETAP",
            "BTOXSGAMMA",
            "BTOXSLL",
            "CB3PI-MPP",
            "CB3PI-P00",
            "Chi0BB1",
            "Chi0BB2",
            "Chi1BB1",
            "Chi1BB2",
            "Chi2BB1",
            "Chi2BB2",
            "ChiPT2pi",
            "ConExc",
            "D_DALITZ",
            "DeBD",
            "DIY",
            "DMIX",
            "ETA_DALITZ",
            "FLATQ2",
            "GOITY_ROBERTS",
            "HAngSam3",
            "HELAMP",
            "HELCOV",
            "HelPPJ",
            "HQET2",
            "HQET",
            "HypNonLepton",
            "HypWK",
            "ISGW2",
            "ISGW",
            "J2BB1",
            "J2BB2",
            "J2BB3",
            "JETSET",
            "JPE",
            "JPIPI",
            "JSCONT",
            "JTO3P",
            "KK_LAMBDAC_SL",
            "KSTARNUNU",
            "KSTARSTARGAMMA",
            "LNUGAMMA",
            "LUNDA",
            "LUNDCHARM",
            "MassH1",
            "MassH2",
            "MBody3",
            "MELIKHOV",
            "mPHSP",
            "D_MULTIBODY",
            "OMEGA_DALITZ",
            "P2GC0",
            "P2GC1",
            "P2GC2",
            "PARTWAVE",
            "PBB1",
            "PBB2",
            "PHI_DALITZ",
            "PHSP",
            "PI0_DALITZ",
            "PYCONT",
            "PYGAGA",
            "PYTHIA",
            "QCO",
            "RhoPi",
            "S0TOS0S0",
            "S0TOS1S0",
            "S0TOS1S1",
            "S0TOS2S0",
            "S0TOS2S1",
            "S0TOS2S2",
            "S0TOS3S0",
            "S0TOS3S1",
            "S0TOS3S2",
            "S0TOS4S0",
            "S0TOS4S1",
            "S0TOS4S2",
            "S0TOS5S0",
            "S1TO3S0",
            "S1TO3S1",
            "S1TO4S0",
            "S1TOS0S0",
            "S1TOS1S0",
            "S1TOS1S1",
            "S1TOS2S0",
            "S1TOS2S1",
            "S1TOS2S2",
            "S1TOS3S0",
            "S1TOS3S1",
            "S1TOS4S0",
            "S1TOS4S1",
            "S2GV",
            "S2TO3S0",
            "S2TOS0S0",
            "S2TOS1S0",
            "S2TOS1S1",
            "S2TOS2S0",
            "S2TOS2S1",
            "S2TOS3S0",
            "S2TOS4S0",
            "S3TOS0S0",
            "S3TOS1S0",
            "S3TOS1S1",
            "S3TOS2S0",
            "S4TOS0S0",
            "S4TOS1S0",
            "S4TOS1S1",
            "S4TOS2S0",
            "S5TOS0S0",
            "SINGLE2",
            "SINGLE",
            "SLBKPOLE",
            "SLL",
            "SLN",
            "SLPOLE",
            "SPL",
            "SSD_CP",
            "SSS_CP",
            "SSS_CP_PNG",
            "SSS_CPT",
            "STS",
            "STS_CP",
            "SVP_CP",
            "SVP_HELAMP",
            "SVS",
            "SVS_CP",
            "SVS_CP_ISO",
            "SVS_CPLH",
            "SVS_NONCPEIGEN",
            "SVV_CP",
            "SVV_CPLH",
            "SVV_HELAMP",
            "SVV_NONCPEIGEN",
            "T2GV",
            "TAUHADNU",
            "TAULNUNU",
            "TAUOLA",
            "TAUSCALARNU",
            "TAUVECTORNU",
            "TSS",
            "TVS_PWAVE",
            "VECTORISR",
            "VLL",
            "VPHOTOVISR",
            "VPHOTOVISRHI",
            "VSP_PWAVE",
            "VSS_BMIX",
            "VSS",
            "VSS_MIX",
            "VUB",
            "VUBHYBRID",
            "VUB_NLO",
            "VVP",
            "VVPIPI",
            "VVPIPI_WEIGHTED",
            "VVS_PWAVE",
            "x1ToKKpipi",
    };

    public EvtModel(EvtPDL pdl){
        modelNameHash=new HashMap<>();
        commandNameHash=new HashMap<>();
        for(String str:ppps){
            register(new EvtDecayBase(str,"",pdl));
        }
    }

    public boolean isModel(String model){
        return modelNameHash.containsKey(model);
    }

    public boolean isCommand(String cmd){
        return commandNameHash.containsKey(cmd);
    }

    public void register(EvtDecayBase prototype){
        modelNameHash.put(prototype.getName(),prototype);
        String tmp=prototype.commandName();
        if(tmp!=null && !tmp.isEmpty()){
            commandNameHash.put(tmp,prototype);
        }
    }

    public void storeCommand(String cmd,String cnfgstr){
        if (commandNameHash.containsKey(cmd)){
            commandNameHash.get(cmd).command(cnfgstr);
        }else{
            throw new RuntimeException();
        }
    }

    EvtDecayBase getFcn(String model_name){
        return modelNameHash.get(model_name).duplicate();
    }
}
